package com.ehome.poct.core.api.vo.order;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

@Data
@Accessors(chain = true)
@NoArgsConstructor
public class OrderItemPriceVO {
    @ApiModelProperty(value = "检测项英文缩写名")
    private String stripNameEn;
    @ApiModelProperty(value = "检测项中文名")
    private String stripNameCn;
    @ApiModelProperty(value = "原价")
    private BigDecimal originPrice;
    @ApiModelProperty(value = "现价")
    private BigDecimal salesPrice;
    @ApiModelProperty(value = "优惠金额")
    private BigDecimal offerMoney;
    @ApiModelProperty(value = "是否具有优惠金额 0 没有 1 具有优惠金额 前端可根据这个做是否展示 显示原价和优惠金额")
    private Boolean showOfferMoney;
    @JsonIgnore
    private Integer inShowOfferMoney;
    @ApiModelProperty(value ="1 单测报告项 2 联测报告项")
    private Integer orderItemType;
    @JsonIgnore
    @ApiModelProperty(value = "报告编码")
    private String reportCode;


    public OrderItemPriceVO(Integer orderItemType ,String stripNameEn,String stripNameCn,BigDecimal originPrice,BigDecimal salesPrice,Integer showOfferMoney,String reportcode){
        this.stripNameEn= stripNameEn;
        this.stripNameCn= stripNameCn;
        this.originPrice= originPrice;
        this.salesPrice= salesPrice;
        this.offerMoney = originPrice!=null? originPrice.subtract(salesPrice):BigDecimal.valueOf(0.00);
        this.inShowOfferMoney = showOfferMoney;
        this.orderItemType= orderItemType;
        this.showOfferMoney= (inShowOfferMoney>0)?((offerMoney.signum()==1)?true:false):false;
        this.reportCode = reportcode;
    }

    public String assemblyTitle() {
        if (StrUtil.isBlank(stripNameCn)) {
            return stripNameEn;
        }
        return stripNameEn + "(" + stripNameCn + ")";
    }
}
